// Package main.
// creator 2022-02-28 01:14:38
// Author  zhenxinma.
package main

import (
	"fmt"

	"gitee.com/zhenxinma/go_common/src/protos"
	"github.com/golang/protobuf/proto"
)

func main() {

	student := &protos.Student{
		Name: "张三",
		Age:  22,
	}

	data, err := proto.Marshal(student)
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	fmt.Println(data)

	// 解析.
	student1 := &protos.Student{}
	proto.Unmarshal(data, student1)
	fmt.Println(student1)

}
